// Copyright DustedPixels.com 2008. All rights reserved.

package com.dustedpixels.jasmin.cycletest;

import com.dustedpixels.jasmin.cycletest.StaticMethodStateArgument.PrivateState;
import com.dustedpixels.jasmin.cycletest.StaticMethodStateArgument.PublicState;


/**
 * @author micapolos@gmail.com (Michal Pociecha-Los)
 */
public final class Benchmark {
  private static final int CYCLES = 35000000;

  public static void main(String[] args) {
    long time;
    
    Base baseSuperclass = new BaseSuperclass();
    for (int i = CYCLES; i != 0; i--) baseSuperclass.process();
    time = System.currentTimeMillis();
    for (int i = CYCLES; i != 0; i--) baseSuperclass.process();
    System.out.println(baseSuperclass + ": " + (System.currentTimeMillis() - time) + "ms");

    NoBaseSuperclass noBaseSuperclass = new NoBaseSuperclass();
    for (int i = CYCLES; i != 0; i--) noBaseSuperclass.process();
    time = System.currentTimeMillis();
    for (int i = CYCLES; i != 0; i--) noBaseSuperclass.process();
    System.out.println(noBaseSuperclass + ": " + (System.currentTimeMillis() - time) + "ms");

    PublicState publicState = new StaticMethodStateArgument.PublicState();
    PrivateState privateState = new StaticMethodStateArgument.PrivateState();
    for (int i = CYCLES; i != 0; i--) StaticMethodStateArgument.process(publicState, privateState);
    time = System.currentTimeMillis();
    for (int i = CYCLES; i != 0; i--) StaticMethodStateArgument.process(publicState, privateState);
    System.out.println(StaticMethodStateArgument.class + ": " + (System.currentTimeMillis() - time) + "ms");
    
    Compiled compiled = new Compiled();
    compiled.process(CYCLES);
    time = System.currentTimeMillis();
    compiled.process(CYCLES);
    System.out.println(compiled + ": " + (System.currentTimeMillis() - time) + "ms");

    CompiledStatic.process(CYCLES);
    time = System.currentTimeMillis();
    CompiledStatic.process(CYCLES);
    System.out.println(CompiledStatic.class + ": " + (System.currentTimeMillis() - time) + "ms");
  }
}
